package com.jellyfishumbrella.noise;

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
//import Functions.Noise;

public class Test_Noise {	
	private static BufferedImage	image;
	static int sizex= 1024; static int sizey = sizex;
	static long seed = 945435435;
	static Noise n = new Noise(seed,sizex);
	static double[][] f = new double[sizex][sizex];
	/*
//	public static void main(String[] args)
//	{
//		long start = System.currentTimeMillis();
//		System.out.println("start");
//		n.reseed_Simplex(seed);
//		image = new BufferedImage(sizex, sizey, BufferedImage.TYPE_3BYTE_BGR);
//		Graphics2D g = image.createGraphics();
//		g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
		//Perlin
//		for(int x=0; x<sizex;x++){
//			for(int y=0;y<sizey;y++){
//				//double pixel = (n.Perlin_Noise(x+.5f,y+.5f,1000,9,2f,.7f));
////				if(pixel > 0){
////					pixel = pixel *.2f;
////				}
//				double pixel = n.Voronoi(x,y);
//				//System.out.println(pixel);
//				image.setRGB(x, y, n.convert_Pixel(pixel));
//			}
//		}
		
		//FBM
//        float x = 0, y = 0, z = 0;
//        for (int v = 0; v < sizex; v++)
//        {
//            x += 0.5f;  y = 0;
//            for (int u = 0; u < sizey; u++)
//            {
//               double pixel = (float)n.fbm(x, y, z, 8, 0.45f, 1.0f);
//               image.setRGB(v, u, n.convert_Pixel(pixel));
//                y += 0.5f;
//            }
//        }
        
		//RMF
//        float x = 0, y = 0, z = 0;
//        for (int v = 0; v < sizex; v++)
//        {
//            x += 0.005f;
//            y = 0;
//            for (int u = 0; u < sizey; u++)
//            {
//                double pixel = (float)n.rmf(x, y, z, 16, 2.85f, 0.45f, 1.0f);
//                image.setRGB(v, u, n.convert_Pixel(pixel));
//                y += 0.005f;
//            }
//        }
		
		//FBM + RMF
		long start1 = System.nanoTime();
	    float x = 0, y = 0, z = 0, x2 = 0, y2 = 0;	      
	    for (int v = 0; v < sizex; v++){
	       x += .1f;  y = 0; x2 += 0.003f; y2= 0;
	       for (int u = 0; u < sizex; u++){ 
	    	  double pixel = n.fbm(x, y, z, 6, 0.55f, .9f);
	          double pixel2 = (((n.rmf(x2, y2, z, 3, 2.85f, 0.55f, 1.0f))))-.5f;
	    	  // double pixel = n.Improved_Noise(x2,y2,0);
	    	   //double pixel =  n.Voronoi(v,u,6,.5f);
	          f[u][v] = pixel2*.9f+pixel*.1f;
	          y += .1f; y2 += 0.003f;   
	       }
	    }
		System.out.println("Produce: "+((System.nanoTime() - start1)/1000000f)+" Milliseconds");
	    
	    for(int y1 = 0; y1 < sizey; y1++){
		    for(int x1 = 0; x1 < sizex; x1++){
		          image.setRGB(x1, y1, n.convert_Pixel(f[x1][y1]));	
		    }
	    }
		g.dispose();
		try{ImageIO.write(image, "png", new File("test2.png"));}catch (IOException e){e.printStackTrace();}	
		System.out.println(System.currentTimeMillis() - start);
		System.out.println("done");
	}
	*/
}
